package genalgoritm.actions;

import genalgoritm.count.Count;
import genalgoritm.editors.ResultEditor;
import genalgoritm.editors.ResultEditorInput;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;

public class RunAction implements IActionDelegate {

	@Override
	public void run(IAction action) {
		Count c = new Count();
		c.count();
		ResultEditorInput input = new ResultEditorInput(c.getResults());
		try {
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
					.openEditor(input, ResultEditor.ID);
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
	}

}
